import { useSessionStorage } from '@hooks/useSessionStorage'

const useAuth = () => {
  const [token, setToken] = useSessionStorage('token', null)
  const [admin, setAdmin] = useSessionStorage('admin', null)

  const logout = () => {
    setToken(undefined)
    setAdmin(undefined)
    sessionStorage.removeItem('login:token')
  }

  return {
    token,
    setToken,
    admin,
    setAdmin,
    logout,
  }
}

export { useAuth }
